Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Readable metrics view url params #5675

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

AdityaHegde
Copy link
Collaborator

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we be backwards compatible with existing reports?

Comment on lines +247 to +252
convertMetricsEntityToURLSearchParams(
dashboard,
url.searchParams,
exploreSpec ?? {},
exploreSpec?.defaultPreset ?? {},
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing to understand what this function does. A pure function could be more clear e.g.:

const searchParams = getURLSearchParamsFromMetricsEntity(...)

$: ({ resourceName } = data.token);
$: ({
basePreset,
partialMetrics,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this partialExploreState?

Comment on lines +53 to +59
toTimeRangesUrl(metrics, searchParams, preset);

toOverviewUrl(metrics, searchParams, explore, preset);

toTimeDimensionUrlParams(metrics, searchParams, preset);

toPivotUrlParams(metrics, searchParams, preset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO pure functions would be easier to understand

} from "@rilldata/web-common/runtime-client";

export function convertMetricsExploreToPreset(
metrics: Partial<MetricsExplorerEntity>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing to see this called "metrics". Can we move toward using exploreState?

explore,
AD_BIDS_TIME_RANGE_SUMMARY,
);
cleanMetricsExplore(initEntity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Comment on lines +489 to +490
// cleans up any UI only state from MetricsExplorerEntity
export function cleanMetricsExplore(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment implies the function name could be removeUIStateFromMetricsExplorerEntity. But doesn't the MetricsExplorerEntity contain all UI/client-side state?

Comment on lines +57 to +59
return {
timeZone: getLocalIANA(),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expect this default/fallback to be included in this function. I'd expect timeZone: getLocalIANA() to be included in the default generic Explore state, which would later be merged with user preferences.

return {
explore,
metricsView,
basePreset,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about initialExploreState?

@@ -16,20 +15,21 @@
const queryClient = useQueryClient();

export let data: PageData;
$: ({ metricsView, explore, basePreset, partialMetrics } = data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing seeing both basePreset and partialMetrics. Could we merge the two of them further upstream?

Comment on lines +39 to +42
const basePreset = getBasePreset(
exploreResource.explore.state?.validSpec ?? {},
getLocalUserPreferencesState(exploreName),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this doesn't belong in this function. Maybe it could be pushed down to a central place where we synthesize the initial state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants